﻿using BCC.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using BCC.Model.user;
using BCC.Common;
using System.Configuration;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
using BCC.Model.ModelsOut;
using BCC.Common.AuthorizationUtils;

namespace BCC.ViewModel.user
{
    public class Getuser
    {
        public static string serverAddress = ConfigurationManager.AppSettings["serverAddress"].Trim();

        /// <summary>
        /// 根据账号查询用户
        /// </summary>
        /// <param name="sendAccount"></param>
        /// <param name="receiveAccount"></param>
        /// <returns></returns>
        public static BCCUser selUserInfo(string Account)
        {
            try
            {
                var url = serverAddress + $"api/User/selUserInfo?Account={Account}";
                var rs = Utils.Get(url);

                var bccUser = JsonConvert.DeserializeObject<BaseOut>(rs);

                if (bccUser.code == "true" && bccUser.content != null)
                {
                    var user = JsonConvert.DeserializeObject<BCCUser>(bccUser.content.ToString());
                    return user;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception)
            {
                return null;
            }
        }

    }
}
